package com.da.auth.config;

import com.da.auth.security.jwt.TokenInterceptor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: hyacinth
 * @CreateTime: 2025-02-12
 * @Version: 1.0
 * <p>
 * Spring 配置类中配置拦截器
 */
@Configuration
@RequiredArgsConstructor
@Slf4j
public class WebConfig implements WebMvcConfigurer {

    private final TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("<==========进入了WebConfig.addInterceptors==========>");
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**") // 拦截所有请求
                .excludePathPatterns("/dl/**"); // 排除登录接口

        log.info("<==========离开了WebConfig.addInterceptors==========>");
    }
}
